﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="report-news-filter.aspx.cs"
    Inherits="MediaMonitor.Users.report_news_filter" MasterPageFile="~/user.master"
    Title="Report Filters - News" %>

<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Src="~/Controls/AutoCompleteExtender.ascx" TagPrefix="ctrl" TagName="AutoComplete" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ContentPlaceHolderID="Head" runat="server">
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
         <script type="text/javascript">

             function DateSelected(sender, eventArgs) {


                 var date1 = eventArgs.get_renderDay().get_date();
                 var dfi = sender.DateTimeFormatInfo;
                 var formattedDate = dfi.FormatDate(date1, dfi.ShortDatePattern);

                 var calE = $find("<%= calE.ClientID %>");
                 var str = date1.toString();
                 var ret = str.split(",");


                 calE.selectDate(date1, true)
                 $('#lblSelectedFromDate').text(ret[0] + '/' + ret[1] + '/' + ret[2]);
                 var str2 = calE.get_selectedDates().toString();
                 var ret2 = str2.split(",");

                 $('#lblSelectedToDate').text(ret2[0] + '/' + ret2[1] + '/' + ret2[2]);

                 //calE.get_selectedDates()
             }
             function DateSelected1(sender, eventArgs) {


                 var date11 = eventArgs.get_renderDay().get_date();

                 var str3 = date11.toString();
                 var ret3 = str3.split(",");


                 $('#lblSelectedToDate').text(ret3[0] + '/' + ret3[1] + '/' + ret3[2]);
                 //calE.get_selectedDates()
             }
        </script>
    </telerik:RadCodeBlock>
</asp:Content>
<asp:Content ContentPlaceHolderID="Body" runat="server">
    <asp:Panel ID="pnlSearch" runat="server" CssClass="report-filter-product">
        <div class="clear">
        </div>
        <h2 class="title">
            <span>Dates</span></h2>
        <div class="five columns  alpha">
         <asp:Label ID="lblSelectedFromDate" runat="server" ClientIDMode="Static" Text=""
                                    Font-Size="16px" ForeColor="Red"></asp:Label>
                                <br />
            <telerik:RadCalendar AutoPostBack="false" ID="calS" runat="server" EnableMultiSelect="false"
                ClientEvents-OnDateSelected="DateSelected">
            </telerik:RadCalendar>
        </div>
        <div class="five columns  alpha">
         <asp:Label ID="lblSelectedToDate" runat="server" ClientIDMode="Static" Text="" Font-Size="16px"
                                    ForeColor="Red"></asp:Label>
                                <br />
            <telerik:RadCalendar AutoPostBack="false" ID="calE" runat="server" EnableMultiSelect="false" ClientEvents-OnDateSelected="DateSelected1">
            </telerik:RadCalendar>
        </div>
        <div class="five columns  alpha">
        <br />
        Days <asp:CheckBoxList ID="chklstDays" runat="server">
                                    <asp:ListItem Value="6" Text="Sunday"></asp:ListItem>
                                    <asp:ListItem Value="0" Text="Monday"></asp:ListItem>
                                    <asp:ListItem Value="1" Text="Tuesday"></asp:ListItem>
                                    <asp:ListItem Value="2" Text="Wednesday"></asp:ListItem>
                                    <asp:ListItem Value="3" Text="Thursday"></asp:ListItem>
                                    <asp:ListItem Value="4" Text="Friday"></asp:ListItem>
                                    <asp:ListItem Value="5" Text="Saturday"></asp:ListItem>
                                </asp:CheckBoxList>
             
          
        </div>
         <br class="h10 clear">
         <h2 class="title">
           </h2>
              <div class="columns  alpha">
               <asp:Button ID="btnLoadLayout" runat="server" CssClass="button"
                ClientIDMode="Static" Text="Load Layout" />
                 </div>


                   <asp:UpdatePanel ID="pnlUpdate" runat="server">
        <ContentTemplate>
        <br class="h10 clear">
        <h2 class="title">
            <span>Media</span></h2>
        <div class="media-data">
            <table class="media-data-table" width="100%">
                <tbody>
                    <tr>
                        <td>
                            Media Type
                        </td>
                        <td>
                            <asp:DropDownList CssClass="aqua_input" ID="lstMediaType" runat="server" AutoPostBack="true"
                                DataValueField="MediaTypeCode" DataTextField="MediaTypeName" OnSelectedIndexChanged="lstMediaType_SelectedIndexChanged" />
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                    <tr valign="top" id="trMedia_TV">
                        <td>
                            Channel / Media Name
                        </td>
                        <td class="media-channels" align="left" style="font-size: small;">
                            <script type="text/javascript">
                                function chkAllMedia_Clicked(obj) {
                                    var selected = document.getElementById('<%=chkAllMedia.ClientID%>').checked;
                                    if (selected)
                                        document.getElementById('dvMediaList').style.display = 'none';
                                    else
                                        document.getElementById('dvMediaList').style.display = 'block';
                                }
                            </script>
                            <asp:CheckBox ID="chkAllMedia" runat="server" Text="Search from all Media Channels"
                                Checked="true" />
                            <div id="dvMediaList" style="display: none;" class="Box">
                                <asp:CheckBoxList ID="lstMedia" runat="server" DataValueField="MediaCode" DataTextField="MediaName"
                                    RepeatColumns="5" RepeatDirection="Horizontal" Font-Size="8px">
                                </asp:CheckBoxList>
                            </div>
                            <script type="text/javascript">
                                document.getElementById('<%=chkAllMedia.ClientID%>').onclick = chkAllMedia_Clicked;
                            </script>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
        <br class="h10 clear">
        <h2 class="title">
            <span>Products</span></h2>
        <div class="columns  alpha">
            <asp:UpdatePanel ID="pnlUpdate_prod" runat="server">
                <ContentTemplate>
                    <p>
                        <label for="">
                            Selector</label>
                        <asp:DropDownList CssClass="aqua_input" ID="lstSector" runat="server" AutoPostBack="true"
                            OnSelectedIndexChanged="lstSector_Changed" DataTextField="SectorName" DataValueField="SectorID" />
                    </p>
                    <p>
                        <label for="">
                            Sub Sector</label>
                        <asp:DropDownList CssClass="aqua_input" ID="lstSubSector" runat="server" AutoPostBack="true"
                            OnSelectedIndexChanged="lstSubSector_Changed" DataTextField="SubSectorName" DataValueField="SubSectorID" />
                    </p>
                    <p>
                        <label for="">
                            Category</label>
                             <asp:LinkButton runat="server" ID="lnkCategory" Text="Click to Select Category" OnClick="lnkCategory_Click"></asp:LinkButton>
                        <asp:HiddenField ID="hdnCategoryIds" runat="server" /><br />
                        <div style="padding-left:92px;">Selected Category(s):-<asp:Label runat="server" ID="lblSelectedCategory" Text=""></asp:Label></div>
                      <%--  <asp:DropDownList CssClass="aqua_input" ID="lstCategory" runat="server" DataTextField="CategoryName"
                            DataValueField="CategoryID" />--%>
                    </p>
                    <br class="h10 clear">
                    <p>
                    </p>
                    <p style="display: none;">
                        <label for="">
                            Advertiser
                        </label>
                        <asp:DropDownList CssClass="aqua_input" ID="lstAdvertiser" runat="server" DataTextField="AdvertiserName"
                            DataValueField="AdvertiserID" />
                    </p>
                </ContentTemplate>
            </asp:UpdatePanel>
            <p class="input-style">
                <label for="">
                    Product</label>
                     <asp:LinkButton runat="server" ID="lnkProduct" Text="Click to Select Product" OnClick="lnkProduct_Click"></asp:LinkButton>
                            <asp:HiddenField ID="hdnProductIDs" runat="server" /><br />
                            <div style="padding-left:92px;">Selected Product(s):-<asp:Label Text="" runat="server" ID="lblSelectedProduct"></asp:Label></div>
                <%--<ctrl:AutoComplete ID="acProduct" runat="server" MinimumPrefixLength="2" ServicePath="~/users/report-news-filter.aspx"
                    ServiceMethod="AutoComplete_FillProduct" completionsetcount="10" />--%>
            </p>
        </div>
        <br class="h10 clear">
        <h2 class="title">
            <span>Options</span></h2>
        <div class="alpha">
            <div class="report-filter-product new-option-filter">
                <p>
                    <label class="label-width" for="">
                        News Section</label>
                    <asp:DropDownList CssClass="aqua_input" ID="lstSection" runat="server" />
                </p>
                <p>
                    <label class="label-width" for="">
                        News Type
                    </label>
                    <asp:DropDownList CssClass="aqua_input" ID="lstNewsType" runat="server" />
                </p>
                <p>
                    <label class="label-width" for="">
                        News Media Types
                    </label>
                    <asp:DropDownList CssClass="aqua_input" ID="lstNewsMediaType" runat="server" />
                </p>
                <p class="price-from input-style">
                    <label for="">
                        Price From
                    </label>
                    <asp:TextBox CssClass="aqua_input" ID="tbPriceFrom" runat="server" Width="80"></asp:TextBox>
                    <asp:RangeValidator ID="rvPriceFrom" runat="server" ControlToValidate="tbPriceFrom"
                        Display="Dynamic" ErrorMessage="Invalid price" MaximumValue="9999" MinimumValue="0"
                        Text="Invalid price" Type="Currency" />
                    <label for="">
                        Price To
                    </label>
                    <asp:TextBox CssClass="aqua_input" ID="tbPriceTo" runat="server" Width="80"></asp:TextBox>
                    <asp:RangeValidator ID="rvPriceTo" runat="server" ControlToValidate="tbPriceTo" Display="Dynamic"
                        ErrorMessage="Invalid price" MaximumValue="9999" MinimumValue="0" Text="Invalid price"
                        Type="Currency" />
                </p>
                <br class="clear" />
                <p style="margin: 0; font-size: 10px;">
                    Download all the videos, audios, or images related to your:</p>
                <asp:CheckBox ID="chkFirstAppearance" runat="server" Checked="false" Text="Show only the first appearance of commerical"
                    Visible="false" />
                <asp:CheckBox ID="chkDownload" runat="server" Checked="false" Text="category" Font-Bold="true" />
                &nbsp;
                <asp:CheckBox ID="chkDownloadProduct" runat="server" Checked="false" Text="product"
                    Font-Bold="true" />
                <br class="clear" />
                <p>
                </p>
                <p class="form-submit">
                    <asp:Button ID="btnSearch" runat="server" OnClick="btnSearch_Click" CssClass="button"
                        Text="Search" />
                    <asp:UpdatePanel ID="pnlUpdate_Submit" runat="server">
                        <ContentTemplate>
                            <asp:Label ID="lblErrorMsg" runat="server" Text="" ForeColor="red"></asp:Label>
                        </ContentTemplate>
                        <Triggers>
                            <asp:AsyncPostBackTrigger ControlID="btnSearch" />
                        </Triggers>
                    </asp:UpdatePanel>
                    <p>
                    </p>
                </p>
            </div>
        </div>
       <asp:HiddenField ID="HiddenField2" runat="server" />
    <asp:ModalPopupExtender ID="ModalPopupExtender3" runat="server" TargetControlID="HiddenField2"
        PopupControlID="Panel2" BackgroundCssClass="modalBackground" CancelControlID="A1">
    </asp:ModalPopupExtender>
    <asp:Panel ID="Panel2" CssClass="pnlpopup" runat="server" BackColor="White" Width="600px"
        Style="display: none;">
        <div class="closebtn">
            <a id="A1" runat="server">X</a></div>
        <div style="overflow-y: scroll; overflow-x: hidden; width: 100%; height: 380px">
            <asp:Label ID="lblNoteCategory1" runat="server" Text="No record found" Visible="false" ForeColor="Red" Font-Size="Larger"></asp:Label>
            <asp:CheckBoxList runat="server" ID="chkCategory" DataTextField="CategoryName" width="100%" DataValueField="CategoryID"
                ValidationGroup="Category">
            </asp:CheckBoxList>
       
        </div>
        <asp:Button ID="btnSaveCategory" runat="server" CssClass="button" Text="Save" OnClick="btnSaveCategory_Click"
            ValidationGroup="Category" />&nbsp;&nbsp;<asp:Button ID="btnCancelCategory" runat="server"
                CssClass="button" Text="Cancel" OnClick="btnCancelCategory_Click" />
          <asp:CustomValidator ID="CustomValidator2" ErrorMessage="Please select at least one item."
        ForeColor="Red" ClientValidationFunction="ValidateCheckBoxListCategory"  ValidationGroup="Category" runat="server" />
         <script type="text/javascript">
             function ValidateCheckBoxListCategory(sender, args) {
                 var checkBoxList = document.getElementById("<%=chkCategory.ClientID %>");
                 var checkboxes = checkBoxList.getElementsByTagName("input");
                 var isValid = false;
                 for (var i = 0; i < checkboxes.length; i++) {
                     if (checkboxes[i].checked) {
                         isValid = true;
                         break;
                     }
                 }
                 args.IsValid = isValid;
             }
    </script>
    </asp:Panel>
  
    <asp:HiddenField ID="HiddenField3" runat="server" />
    <asp:ModalPopupExtender ID="ModalPopupExtender4" runat="server" TargetControlID="HiddenField3"
        PopupControlID="Panel3" BackgroundCssClass="modalBackground" CancelControlID="A2">
    </asp:ModalPopupExtender>
    <asp:Panel ID="Panel3" CssClass="pnlpopup" runat="server" BackColor="White" Width="600px"
        Style="display: none;">
        <div class="closebtn">
            <a id="A2" runat="server">X</a></div>
        
                <div style="overflow-y: scroll; overflow-x: hidden; width: 100%; height: 380px">
                <asp:UpdatePanel ID="udpInnerUpdatePanel" runat="Server" UpdateMode="Conditional">
            <ContentTemplate>
             <asp:Label ID="lblNoteProduct" runat="server" Text="No record found" Visible="false" ForeColor="Red" Font-Size="Larger"></asp:Label>
                    <asp:CheckBoxList runat="server" ID="chkProduct" DataTextField="ProductName" Width="100%" DataValueField="ProductID"
                        ValidationGroup="Product">
                    </asp:CheckBoxList>
                    </ContentTemplate>
                    
        </asp:UpdatePanel>
                    <script>
                        function ValidateModuleList(source, args) {

                            var chkListModules = document.getElementById('<%= chkProduct.ClientID %>');
                            var chkListinputs = chkListModules.getElementsByTagName("input");
                            for (var i = 0; i < chkListinputs.length; i++) {
                                if (chkListinputs[i].checked) {
                                    args.IsValid = true;
                                    return;
                                }
                            }
                            args.IsValid = false;
                        }
                    </script>
                </div>
                <asp:Button ID="btnSaveProduct" runat="server" CssClass="button" Text="Save" OnClick="btnSaveProduct_Click"
                    ValidationGroup="Product" />&nbsp;&nbsp;<asp:Button ID="btnCancelProduct" runat="server"
                        CssClass="button" Text="Cancel" OnClick="btnCancelProduct_Click" />
                <asp:CustomValidator runat="server" ID="CustomValidator1" ClientValidationFunction="ValidateModuleList"
                    ErrorMessage="Please Select Atleast one Product" ValidationGroup="Product"></asp:CustomValidator>
            
    </asp:Panel>
    
    </ContentTemplate>
    <Triggers>
    <asp:AsyncPostBackTrigger ControlID="lnkCategory" />
    </Triggers>
        </asp:UpdatePanel>
    </asp:Panel>
     <script type="text/javascript">


         function ShowProgress() {
             document.getElementById('<% Response.Write(updateProgress.ClientID); %>').style.display = "inline";
         }
    

    </script>
    <asp:UpdateProgress id="updateProgress" runat="server">
     <ProgressTemplate>
            <div style="position: fixed; text-align: center; height: 100%; width: 100%; top: 0; right: 0; left: 0; z-index: 9999999; background-color: #000000; opacity: 0.7;">
                    <asp:Image ID="imgUpdateProgress" runat="server" ImageUrl="~/assets/loader.gif" AlternateText="Loading ..." ToolTip="Loading ..." style="padding: 10px;position:fixed;top:45%;left:50%;" />
            </div>
     </ProgressTemplate>
</asp:UpdateProgress>
</asp:Content>
